package com.srxz.mobilepharmacy.service;

import com.srxz.mobilepharmacy.entity.Hospital;
import com.srxz.mobilepharmacy.mapper.mapstruct.HospitalMapper;
import com.srxz.mobilepharmacy.repository.HospitalRepository;
import com.srxz.mobilepharmacy.service.mapstruct.HospitalDTOService;
import com.srxz.mobilepharmacy.util.back.BackMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class HospitalService extends HospitalDTOService {
    @Autowired
    private HospitalRepository hospitalRepository;
    @Autowired
    private HospitalMapper hospitalMapper;

    public BackMessage findhospitals(){
        List<Hospital> hospitals = hospitalRepository.findAll();
        return BackMessage.success().putData("hospitals", hospitalMapper.dto(hospitals));
    }
}
